﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicCommon;
using T_Material.Domain;
using T_Material.Read.API.Application.Commands.RequisitionCommand;
using T_Material.Read.API.Application.Commands.StatisticsCommand;

namespace T_Material.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class StatisticsRApiController : ControllerBase
    {
        private readonly IMediator mediator;

        public StatisticsRApiController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 物资统计列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Statistics>> StatisticsList([FromQuery] StatisticsListCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 根据物资统计Id找到统计实体
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Statistics> StatisticsInfo([FromQuery] StatisticsInfoCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
